package com.test4;

/*****
 *输出线程
 */
public class OutThread  extends Thread {
	private Res res;

	public OutThread(Res res) {
		this.res = res;
	}

	@Override
	public void run() {
		while (true) {
			try {
				res.lock.lock();
				if (!res.flag) {
					try {
						res.condition.await();
					} catch (Exception e) {
					}
				}
				System.out.println(res.userName + "--" + res.userSex);
				res.flag = false;
				res.condition.signal();
			} catch (Exception e) {
			} finally {
				res.lock.unlock();
			}
		}
	}

}